﻿using System;
using System.Linq;

class BinarySearch
{
    static void Main()
    {
        int numberToFind = 11;
        int[] array = { 1, 3, 9, 11, 18, 22, 28, 29, 35, 180 };

        int endNumber = array.Length - 1;
        for (int startNumber = 0; startNumber <= endNumber;)
        {
            if (numberToFind > array[(startNumber + endNumber) / 2])
            {
                startNumber = (startNumber + endNumber) / 2;
            }
            else if (numberToFind < array[(startNumber + endNumber) / 2])
            {
                endNumber = (startNumber + endNumber) / 2;
            }
            else
            {
                Console.WriteLine((startNumber + endNumber) / 2);
                break;
            }
        }
    }
}